﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp34
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            WriteableBitmap writeableBitmap = new(200, 200, 96, 96, PixelFormats.Bgra32, null);

            //可以进行相关的操作
            //写像素
            byte b = 0xFF;
            byte g = 0x00;
            byte r = 0x00;
            byte a = 0xFF;

            byte[] buf = { b, g, r, a };
            for (int i = 0; i < 20; i++)
            {
                Int32Rect rect = new Int32Rect(i, i, 1, 1);
                writeableBitmap.WritePixels(rect, buf, 4, 0);
            }
            image.Source = writeableBitmap;

        }


    }
}